<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:p="http://primefaces.org/ui">
      <f:view>
      <f:metadata>
		<ui:param name="originalURLS" value="#{request.requestURI}?#{request.queryString}" />
		
			<f:event rendered="#{not userSession.loggedIn}" type="preRenderView"
				listener="#{userSession.recordOriginalURL(originalURLS)}" />
		</f:metadata>
	</f:view>

	<h:head><h1>Ricerca/Visualizza Pacchetti</h1>
		    <style type="text/css">
        .ui-layout-unit{
             border: none;
        }
    </style>
			<link type="text/css" href="./generalstyle.css" rel="stylesheet"/>
	
	
	</h:head>
<body>

	<img src="http://www.mediterraneanfood.it/pacco2.gif" alt=""
		height="200" width="300" />
	 <h:form>
        <p:menubar>  
                <p:menuitem value="Home" url="./home.xhtml" />  
				<p:menuitem value="Area Cliente" url="./cliente/homeCliente.xhtml" />
				<p:menuitem value="Area Impiegato" url="./impiegato/homeImpiegato.xhtml" /> 
				<p:menuitem value="Login" url="./login.xhtml" rendered="#{request.remoteUser == null}" />
                <p:menuitem value="Logout" actionListener="#{logoutManagedBean.logout()}" rendered="#{request.remoteUser != null}" />
		</p:menubar>
		</h:form>	
	<h:form>
		<p:layout style=" height:80px;">
			<p:layoutUnit position="west" size="150">
				<p:outputLabel for="idPersonalizzato" value="Id Pacchetto" />
			</p:layoutUnit>
			
			<p:layoutUnit position="east">
				<p:commandButton value="CERCAID" actionListener="#{PacchettoManagedBean.cercaPacchettiPers()}" ajax="false" />
			</p:layoutUnit>

			<p:layoutUnit position="center">
				<p:inputText id="idPersonalizzato" value="#{PacchettoManagedBean.idPersonalizzato}" requiredMessage="Campo obbligatorio" />
			</p:layoutUnit>
		</p:layout>
		
		<p:layout style=" height:80px;">
			<p:layoutUnit position="west" size="150">
				<p:outputLabel for="cerca" value="Nome Pacchetto" />
			</p:layoutUnit>
			
			<p:layoutUnit position="east">
				<p:commandButton value="CERCA" actionListener="#{PacchettoManagedBean.cercaPacchetti()}" ajax="false" />
				<p:commandButton value="VISUALIZZA" actionListener="#{PacchettoManagedBean.visualizzaPacchetti()}" ajax="false" />
			</p:layoutUnit>

			<p:layoutUnit position="center">
				<p:inputText id="cerca" value="#{PacchettoManagedBean.cerca}" requiredMessage="Campo obbligatorio"  />
			</p:layoutUnit>
		</p:layout>
	
	</h:form>
	
	
	<ui:repeat value="#{PacchettoManagedBean.pacchetti}" var="packCorr"
			varStatus="statoPack">
	<h:form>
			<p:layout style=" height:200px;">
				<p:layoutUnit position="center">
				
					<p:layout style="height:50px;" >
						<p:layoutUnit position="west" size="200">
							<p:outputLabel value="Nome Pacchetto: " />
							<p></p>
							<p:outputLabel value="Numero Persone: " />
							<p></p>
							<p:outputLabel value="Data Partenza: " />
							<p></p>
							<p:outputLabel value="Data Ritorno: " />
							<p></p>
							<p:outputLabel value="Prezzo: " />
						</p:layoutUnit>
						
						<p:layoutUnit position="center">
							<p:outputLabel id="nome" value="#{packCorr.nome}" />
							<p></p>
							<p:outputLabel id="numeroPersone" value="#{packCorr.numeroPersone}"/>
							<p></p>
							<p:outputLabel id="dataPartenza" value="#{packCorr.dataPartenza}"/>
							<p></p>
							<p:outputLabel id="dataRitorno" value="#{packCorr.dataRitorno}"/>
							<p></p>
							<p:outputLabel id="Prezzo" value="#{packCorr.prezzo}"/>
						</p:layoutUnit>
					</p:layout>
					
				</p:layoutUnit>
				<p:layoutUnit position="east" size="600">
					<p:commandButton
						actionListener="#{PacchettoManagedBean.aggiungiACarrello(PacchettoManagedBean.pacchetti.get(statoPack.index).idPacchetto)}"
						value="+CARRELLO" ajax="false"  />
					<p></p>
					<p:commandButton
						actionListener="#{PacchettoManagedBean.aggiungiAWishlist(PacchettoManagedBean.pacchetti.get(statoPack.index).idPacchetto)}"
						value="+WISHLIST" ajax="false"  />
					<p></p>
					 <p:button outcome="./personalizzaPacchetto.xhtml?id=#{PacchettoManagedBean.pacchetti.get(statoPack.index).idPacchetto}&amp;crea=true" value="MODIFICA" />
				</p:layoutUnit>
			</p:layout>
		</h:form>
				</ui:repeat>
		
</body>
</html>